{template 'header'}
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" href="../addons/mx_shop/resources/cgc/css/member/oldphone.css">
<body>
<header class="mui-bar mui-bar-nav" style="background: #72adf5;">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white;"></a>
    <h1 class="mui-title" id="title" style="color: white;">更换手机号</h1>
</header>
<div class="content" id="content">
    <div class="inputwrap">
        <div class="tel">
            <span>你当前手机号:</span>
            <span class="phonum">17775608995</span>
        </div>
        <div class="code">
            <div class="mui-input-row">
                <i class="iconfont icon-buchongiconsvg02"></i>
                <input type="text" placeholder="输入验证码" class="yzm">
            </div>
            <button @click="funYzm()" class="send_yzm">获取验证码</button>
        </div>
        <div class="btn">
            <button type="button" class="mui-btn next" style="color:#fff" @click="next()">下一步</button>
        </div>
        <input type="hidden" value="{$token}" id="token">
    </div>
</div>
<script>
    var vm =new Vue({
        el:"#content",
        data:{

        },
        methods:{
            funYzm:function () {
                console.log(1);
                var phonum = $(".phonum").text(),
                    token = $("#token").val();

                var _this = this;
                var time =60;

                this.flag = false;

                this.$http({
                    method:'POST',
                    url:mainApp.getUrl('sms/getRegCode'),
                    params:{temp:'sms_reg',phone:phonum,token:token},
                    emulateJSON:true
                }).then(function(msg){
                    console.log(msg);
                    if(msg.data.status==1){
                        $.succeed("发送成功");
                        var timer=setInterval(function(){
                            time--;
                            $(".send_yzm").text(time+'s');
                            if(time==0){
                                $(".send_yzm").text("获取验证码");
                                _this.flag=true;
                                clearInterval(timer);
                                time=60;
                            }
                        },1000);
                    }else{
                        _this.flag=true;
                        $.show(msg.data.result.message);
                     }

                });
            },
            next:function(){
                var phonum = $(".phonum").text(),
                    yzm = $(".yzm").val();
                    token = $("#token").val();

                this.$http({
                    method:'POST',
                    url:mainApp.getUrl('member/oldphone'),
                    params:{phone:phonum,sms_code:yzm,token:token},
                }).then(function(msg){
                    console.log(msg);
                    // if(msg.data.status==1){
                    //     $.succeed("注册成功");
                    //     setTimeout(function(){
                    //         window.location.href=mainApp.getUrl('user/login');
                    //     },1000);
                    // }else{
                    //     $.show(msg.data.result.message);
                    // }
                });
            }
        }
    });
</script>
</body>
</html>